﻿using System;
using System.Net;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DomainDriver.Presentation.Silverlight.Base
{
    public delegate void RefreshRequestHandler(object sender, RefreshRequestEventArgs args);

    public class RefreshRequestEventArgs : RoutedEventArgs
    {
        private string m_RequestedMethodName;
        private OperationBase m_CompletedOperation;

        public RefreshRequestEventArgs()
            : this(null, null)
        { }

        public RefreshRequestEventArgs(string requestedMethodName)
            : this(requestedMethodName, null)
        { }

        public RefreshRequestEventArgs(OperationBase completedOperation)
            : this(null, completedOperation)
        { }

        public RefreshRequestEventArgs(string requestedMethodName, OperationBase completedOperation)
        {
            m_RequestedMethodName = requestedMethodName;
            m_CompletedOperation = completedOperation;
        }

        public bool WasSpecificMethodRequested
        {
            get { return (!string.IsNullOrWhiteSpace(m_RequestedMethodName)); }
        }

        public string RequestedMethodName
        {
            get { return m_RequestedMethodName; }
        }

        public bool WasOperationCompleted
        {
            get { return (m_CompletedOperation != null); }
        }

        public OperationBase CompletedOperation
        {
            get { return m_CompletedOperation; }
        }

        public OP_TYPE GetTypedCompletedOperation<OP_TYPE>()
            where OP_TYPE : class
        {
            return m_CompletedOperation as OP_TYPE;
        }
    }
}